import { createAction } from 'redux-actions'
import { LOGIN } from '../types'
import api from './api'

export const login = createAction(LOGIN, async ({ code, photo, nickname }) => {
  let result = {}
  try {
    result = await api({
      url: `/weixin/login`,
      method: 'POST',
      data: {
        code,
        auth: 'weixin',
        photo,
        nickname
      }
    })
  } catch (error) {
    return result
  }
  return result
})

export default {}
